// 从插件内导出createRouer.createWebHashHistory
import { createRouter , createWebHashHistory } from "vue-router";

import LoginCom from "@/components/LoginCom.vue";
import HomeCom from "@/components/HomeCom.vue";
import AddPerson from "@/components/AddPerson.vue";
import ListPerson from "@/components/ListPerson.vue";
// 定义路由表
const routes = [
    {path:'/',
    // redirect:{
    //     name:'LoginCom'
    // }
    redirect:'/login'
    },
{
    path:'/login',
    name:"LoginCom",
    component:LoginCom
},
{
    path:'/home',
    name:"HomeCom",
    component:HomeCom,
    children:[
        {
            path:'/AddPerson',
            name:"AddPerson",
            component:AddPerson,
        },
        {
            path:'/ListPerson',
            name:"ListPerson",
            component:ListPerson,
        }
    ]
}
];

// 定义路由器/创建新路由器
const router =createRouter({
    // 调用路由表，实现router-link的跳转以及router-view的渲染
    // routes:routes,
    routes,
    // 将路由历史模式设置为hash模式(哈希历史)
    history:createWebHashHistory(),
});

// 导出路由器
export default router;